<?php
namespace app\home\controller;
use think\Controller;
use think\Db;
class Login extends Controller{
	public function index(){
		$house = getHouseList();
		$this->assign('houseList',$house);
		return $this->fetch('index');
	}
	public function login(){
		$houseId = input('houseId/d');
		$userName = input('userName');
		$userPwd = input('userPwd');
		$houseName = '';
		$rs = checkUserLogin($userName,$userPwd);
		if($rs['status'] < 0){
			return $rs;
			exit;
		}
		$config = getConfigByHouse($houseId);
		if(empty($config)){
			$data['status'] = -1;
			$data['msg'] = '获取配置文件失败,请选择正确的磅房或是联系管理员';
			$data['data'] = array();
			return $data;
			exit;
		}
		session('TX_USERS',$rs['data']);
		$house = getHouseById($houseId);
		if(!empty($house)){
			session('TX_HOUSE',$house);
		}
		$data['status'] = 1;
		$data['msg'] = 'ok';
		$data['data'] = $rs['data'];
		$data['config'] = $config;
		return $data;
	}
}
?>